package com.ht.modules.component.ai.session.service;

import dev.langchain4j.data.message.ChatMessage;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 持久化聊天记录
 */
@Component
@Slf4j
public class SessionChatStoreService implements ChatMemoryStore {
    @Autowired
    private SessionDbService sessionDbService;

    public List<ChatMessage> getMessages(Object memoryId) {
        return sessionDbService.getMessages(String.valueOf(memoryId));
    }
    public void updateMessages(Object memoryId, List<ChatMessage> chatMessageList) {
        sessionDbService.updateMessages(String.valueOf(memoryId), chatMessageList);
    }
    public void deleteMessages(Object memoryId) {
        sessionDbService.deleteMessages(String.valueOf(memoryId));
    }
}
